package com.zz.charset;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

public class Test {
    public static void main(String args[]) throws Exception {
        String data ="a我b" ;
        byte[] bytes = data.getBytes();//默认字符集（UTF-8)
        System.out.println(Arrays.toString(bytes));

        //指定字符集
        byte[] bytes1 = data.getBytes("GBK");
        System.out.println(Arrays.toString(bytes1));

        //解码
        String s1 = new String(bytes);
        System.out.println(s1);

        String s2 = new String(bytes1,"GBK");//指定字符集解码
        System.out.println(s2);
    }
}
